package com.service.gmall.product.controller;

import com.service.gmall.common.result.Result;
import com.service.gmall.product.service.FileuploadService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestPart;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

/**
 * @author alpha
 * @className: FileuploadController
 * @date 2022/8/24 14:24
 * @Description
 */

@RequestMapping("/admin/product")
@RestController
public class FileuploadController {

    @Autowired
    FileuploadService fileuploadService;
    //文件上传
    @PostMapping("/fileUpload")
    public Result fileUpload(@RequestPart("file")MultipartFile file) throws Exception {
        String url = fileuploadService.upload(file);
        return Result.ok(url);
    }
}
